package ThreadDemo;

/**
 * @author:周鹏
 * @date: 2020/11/12 10:57
 * @description:
 */
public class ObserverThread {
//    @Override
//    public void run() {
//        for (int i=0;i<=100;i++){
//            try {
//                Thread.sleep(100);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            System.out.println("线程终止///");
//
//        }
//    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            for (int i=0;i<=5;i++){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }


        }

        );
        //
        Thread.State state=t1.getState();
        System.out.println(state);
//
        t1.start();
        state=t1.getState();
        System.out.println(state);
        while(state!=Thread.State.TERMINATED){
            Thread.sleep(100);
            state=t1.getState();
            System.out.println(state);

        }

    }
}
